<script>
  let count = 0;
  const price = 25.3;
  let total = 0;
  const add = () => {
    count++;
  };
  const reduce = () => {
    if (count <= 0) return;
    count--;
  };
  $: console.log("count changed: ", count);
  $: total = count * price;
</script>

<main>
  <button on:click={add}>+</button>
  <p>{count}</p>
  <button on:click={reduce}>-</button>
  <p>总价为：{total}</p>
</main>
